package com.qf.util;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

/**
 * @author Ypl
 * @version V1.0
 * @Project OctoberAndNovember
 * @Package com.qf.util
 * @Description:
 * @Date 2022/11/5 17:24
 */
@SuppressWarnings("all")
public class ZkClientUtil {

    public static CuratorFramework getZkClient(){
        RetryPolicy retryPolicy = new ExponentialBackoffRetry(2000,2);

        //创建集群节点连接操作对象
        CuratorFramework curatorFramework = CuratorFrameworkFactory.builder()
                .connectString("192.168.11.100:2184,192.168.11.100:2182,192.168.11.100:2183") //集群的ip
                .retryPolicy(retryPolicy)
                .build();
        //开始连接
        curatorFramework.start();

        //返回对象
        return curatorFramework;
    }
}
